<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <script th:src="@{/erp/assets/js/jquery.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
</head>
<body>


<form>
    <!--销售区域分配图层-->
    <div class="add_menber" id="add_menber_style">
        <ul class=" page-content">
            <div class="Operate_cont clearfix">
                <label class="form-label"><span class="c-red">*</span>仓库名称：</label>
                <div class="formControls ">
                    <!--下拉框-->
                    <select name="warehouseId" required id="warehouseName" style="margin-left:10px;">
                        <option value="" selected disabled>--请选择仓库--</option>
                    </select>
                </div>
            </div>
            <!--<div class="Operate_cont clearfix">
                <label class="form-label"><span class="c-red">*</span>仓库编号：</label>
                <div class="formControls " style="width:280px;">
                    <input type="text" required class="input-text" value="" placeholder="" id="areaNo" name="areaNo">
                </div>
            </div>-->

            <div class="Operate_cont clearfix">
                <label class="form-label"><span class="c-red">*</span>货区名称：</label>
                <div class="formControls ">
                    <input type="text" required class="input-text" value="" placeholder="" id="areaName"
                           name="areaName">
                </div>
            </div>
            <div class="Operate_cont clearfix">
                <label class="form-label"><span class="c-red">*</span>货区编号：</label>
                <div class="formControls ">
                    <input type="text" required class="input-text" value="" placeholder="" id="areaNo" name="areaNo">
                </div>
            </div>
            <div class="Operate_cont clearfix">
                <label class="form-label"><span class="c-red">*</span>区域面积：</label>
                <div class="formControls ">
                    <input type="text" required="required" class="input-text" value="" placeholder="/平方米" id="" name="areaMj">
                </div>
            </div>
            <div class="Operate_cont clearfix">
                <label class="form-label"><span class="c-red">*</span>货区描述：</label>
                <div class="formControls "><textarea th:required="required" name="areaRemark"></textarea>
                </div>
            </div>

            <div class="" style=" text-align:center">
                <input class="btn btn-primary" id="tijiao" type="submit" value="提交">
                <input class="btn btn-primary" id="tijiao1" type="reset" value="取消">
            </div>
        </ul>
    </div>
</form>
<script>
    jQuery(function ($) {
            $.ajax({
              url: '/warehouse/list',
                type:'post',
                success:function (res) {
                  for (var i= 0;i<res.length;i++){
                      $("#warehouseName").append('<option value="'+res[i].id+'">'+res[i].warehouseName+'</option>')
                  }
                }
            })

        $('form').submit(function () {
            var data = $('form').serialize();
            $.ajax({
                url: '/area/add',
                type:'post',
                data: data,
                success:function (res) {
                    if (res.rs) {
                        parent.layer.msg(res.msg, {icon: 1});
                        $('#btn',parent.window.document).click();
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
            return false;
        });

        $('#tijiao1').on('click', function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });
    });


</script>
</body>
</html>